﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHealthOnline.Dal.Generated.CollectionClasses;
using MyHealthOnline.Dal.Generated.EntityClasses;
using MyHealthOnline.Business;

namespace MyHealthOnline.Specialist
{
    public partial class Consultations : System.Web.UI.UserControl
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public void SetGrid(ConsultCollection consults, string emptyDataText="No data")
        {
            Consults = consults;
            grdConsultationsPatients.DataSource = consults;
            grdConsultationsPatients.DataBind();
            grdConsultationsPatients.EmptyDataText = emptyDataText;
        }
        public ConsultCollection Consults
        {
            get
            {
                return ViewState["Consults"] as ConsultCollection;
            }
            set
            {
                ViewState["Consults"] = value;
            }
        }
      
        protected void grdConsultationsPatients_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index=Convert.ToInt32(e.CommandArgument);
            if (e.CommandName == "View" || e.CommandName=="Open")
            {
                int id = Convert.ToInt32(grdConsultationsPatients.DataKeys[index].Value);
                Response.Redirect(string.Format("~/Specialist/OpenConsult.aspx?ConsultId={0}", id));
            }
            
        }

    }
}